/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package masters.servlet.insumos;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import masters.dao.InsumosDAO;
import masters.excepcion.DAOExcepcion;
import masters.modelo.Insumos;

/**
 * Servlet implementation class for Servlet: UsuarioInsertarServlet
 *
 */
public class InsumosInsertarServlet extends javax.servlet.http.HttpServlet
		implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	/*
	 * (non-Java-doc)
	 *
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public InsumosInsertarServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 *
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Java-doc)
	 *
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		//
		String a = request.getParameter("idInsumos");
                int aa = Integer.valueOf(a);
		String b = request.getParameter("tipo_tela");
		String c = request.getParameter("cantidad_tela");
		String d = request.getParameter("precio_tela");
		String e = request.getParameter("color_tela");
		String f = request.getParameter("color_hilo");
                String g = request.getParameter("cantidad_hilo");
                String h = request.getParameter("precio_hilo");




		Insumos vo = new Insumos();
                vo.setIdinsumos(aa);
		vo.setTipo_tela(b);
		vo.setCantidad_tela(c);
		vo.setPrecio_tela(d);
		vo.setColor_tela(e);
		vo.setColor_hilo(f);
                vo.setCantidad_hilo(g);
                vo.setPrecio_hilo(h);



		InsumosDAO dao = new InsumosDAO();
		try {
			dao.insertar(vo);
			RequestDispatcher rd = request
					.getRequestDispatcher("/admininsumos.jsp");
			rd.forward(request, response);
		} catch (DAOExcepcion e1) {
			System.err.println("Error");
			RequestDispatcher rd = request.getRequestDispatcher("/error.jsp");
			rd.forward(request, response);
		}

	}
}